-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Remove unwraps from metadata decoding: introduce BlobDecoder
#149455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
These commits modify compiler targets. |
25b88c6 to
cf9344a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc: @oli-obk this is what I was talking about. not yet clean, but wanted to see what perf looked like :3 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 694a8a4 failed: CI. Failed jobs:
|
cf9344a to
bed17cf
Compare
|
@bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (7ac6e1b): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.041s -> 471.157s (0.02%) |
|
The large workspace benchmark shows improvements in not just instructions, but also time on the write dep info query. Everything else is a mixed bag on time, unsure why other queries are affected. There are minimal improvements for incremental loading across the board. I'm guessing I'm general the branch predictor just got this all correct. |
524ba79 to
285c9b1
Compare
| fn decoder(self, pos: usize) -> Self::Context; | ||
| } | ||
|
|
||
| impl<'a> Metadata<'a> for &'a MetadataBlob { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
importantly there are now only two, not 5 implementations of Metadata.
- One for
MetadataBlobwhich provides only theBlobDecodeContextwhich only implementsBlobDecoder - One for
(tcx, cdata)which provides theMetadataDecodeContextwhich does implementSpanDecoderandTyDecoder.
This makes it statically known whether we have tcx and cdata available, and whether spans etc can be decoded or not.
| fn decode<'a, 'tcx, M: Metadata<'a>>(self, metadata: M) -> T::Value<'tcx> | ||
| where | ||
| T::Value<'tcx>: Decodable<DecodeContext<'a, 'tcx>>, | ||
| T::Value<'tcx>: Decodable<M::Context>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decodable specifically with the Context type from whichever kind of M: Metadata is given.
| impl<'a, 'tcx> MetadataDecodeContext<'a, 'tcx> { | ||
| #[inline] | ||
| fn tcx(&self) -> TyCtxt<'tcx> { | ||
| let Some(tcx) = self.tcx else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap removed
| if let Some(alloc_decoding_session) = self.alloc_decoding_session { | ||
| alloc_decoding_session.decode_alloc_id(self) | ||
| } else { | ||
| bug!("Attempting to decode interpret::AllocId without CrateMetadata") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap removed
| let cdata = self.cdata(); | ||
|
|
||
| let Some(sess) = self.sess else { | ||
| bug!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap removed
| let local_cdata = self.cdata(); | ||
|
|
||
| let Some(sess) = self.sess else { | ||
| bug!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap removed
| let hi = lo + len; | ||
|
|
||
| let Some(sess) = decoder.sess else { | ||
| bug!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap removed
| cfg_version: &'static str, | ||
| ) -> Result<(), Option<String>> { | ||
| if !self.blob().starts_with(METADATA_HEADER) { | ||
| if self.blob().starts_with(b"rust") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these blob calls were very funny, since it gets an instance of Metadatablob... But these are methods implemented on MetadataBlob.
| .decode((self, tcx)) | ||
| } | ||
|
|
||
| fn load_proc_macro<'tcx>(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> SyntaxExtension { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make things consistent, I always pass tcx first. There are one or two cases where this meant I moved the existing tcx argument.
|
@oli-obk I think this is ready :) Left you some review notes |
This comment has been minimized.
This comment has been minimized.
285c9b1 to
ca97283
Compare
|
|
BlobDecoder
r? @oli-obk